﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Collections.Generic;

namespace QuangMobile
{
    public partial class NhomSanPham : System.Web.UI.Page
    {
        private int mod = -1;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["mod"] != null)
            {
                mod = Convert.ToInt32(Request.QueryString["mod"]);
                LoadProductBlockList(mod);
            }
        }

        protected void LoadProductBlockList(int ID)
        {
            string sql = "SELECT TenDM FROM dbo.tblWebDanhMuc WHERE ID = " + ID;
            UCProductBlock Block = (UCProductBlock)LoadControl("UCProductBlock.ascx");
            Block.Title = SqlHelper.ExecuteScalar(CommandType.Text, sql).ToString();
            string sSql = "SELECT * FROM dbo.tblWebSanPham WHERE NhomID_DM = @ID";
            List<SqlParameter> arrParams = new List<SqlParameter>();
            arrParams.Add(SqlHelper.CreateParameterObject("@ID", SqlDbType.Int, ParameterDirection.Input, ID));
            DataTable Pdt = SqlHelper.ExecuteDataTable(CommandType.Text, sSql, arrParams);
            Block.ListProduct = Pdt;
            ProductBlockList.Controls.Add(Block);
        }
    }
}
